package cn.com.thread;

/**
 * 线程状态
 */
public class ThreadStatus {

    public static void main(String[] args) throws InterruptedException {
        TargetStatusDemo1 statusDemo1 = new TargetStatusDemo1();
        Thread thread = new Thread(statusDemo1);
        System.out.println("当前线程状态：" + thread.getState());  //NEW
        thread.start();
        System.out.println("当前线程状态：" + thread.getState());  //RUNNABLE
        Thread.sleep(100);
        System.out.println("当前线程状态：" + thread.getState());  //TIMED_WAITING
        Thread.sleep(2000);
        System.out.println("当前线程状态：" + thread.getState());  //WAITING
        Thread.sleep(3000);
        synchronized (statusDemo1){
            statusDemo1.notify();
        }
        System.out.println("当前线程状态：" + thread.getState());  //BLOCKED
        Thread.sleep(3000);
        System.out.println("当前线程状态：" + thread.getState());  //TERMINATED
    }
}
